'use strict';

const ConsoleLogWriter = require('./console_log_writer');

class Logger {
  constructor(loggerName, writer) {
    this.loggerName = loggerName;
    this.writer = writer || new ConsoleLogWriter();
  }

  clear() {
    this.writer.write('', true);
  }

  /**
   * 记录普通日志
   * @param {String} data 日志字符串
   */
  info(data) {
    const logString = `[${this.loggerName}] [${new Date().toISOString()}] [INFO] ${data}`;
    this.writer.write(logString);
  }
}

module.exports = Logger;
